package JSE_02.Map.Demo07;

import java.util.HashMap;
import java.util.Scanner;

public class MapTest {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个字符串:");
        String str=sc.next();
        HashMap<Character,Integer> map=new HashMap<>();
        for(char c:str.toCharArray()){
            if(map.containsKey(c)){
                Integer value=map.get(c); // get()获取的是value值
                value++;
                map.put(c,value);
            }else{
                map.put(c,1);
            }
        }

        for(Character key: map.keySet()){
            System.out.println(key+"出现了"+map.get(key)+"次");
        }
    }
}
